package com.sbl.bajw.pc.action;

import java.util.HashMap;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.log4j.Logger;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.sbl.bajw.common.web.JsonResultUtil;
import com.sbl.bajw.common.web.RequestUnit;
import com.sbl.bajw.pc.model.AppLogModel;
import com.sbl.bajw.pc.service.AppLogService;
import com.sbl.bajw.util.LogUtil;

@Controller
@RequestMapping("/AppLog")
public class AppLogAction {
	
	@Resource
	private AppLogService service;
	
	static Logger log;
	
	static{
		log = LogUtil.getLogger("applog");
	}
	
	@RequestMapping(value = "/add")
	public @ResponseBody String insert(HttpServletRequest request, HttpServletResponse response) throws Exception{
		AppLogModel model = RequestUnit.getModel(AppLogModel.class);
		String userid = RequestUnit.getString("user_id");
		model.setUserId(userid);
		log.info(model.toString());
		service.insert(model);
		
		return JsonResultUtil.Success();
	}
	
	/**
	 * APP日志查询
	 * 用于列表展示
	 * @作者：罗琦
	 * @param request
	 * @param response
	 * @return
	 */
	@RequestMapping(value = "/getAppLogList")
	public @ResponseBody String getAppLogList(HttpServletRequest request, HttpServletResponse response){
		HashMap<String, Object> parm = RequestUnit.getHashMapParmO();
		String json = service.getAppLogList(parm);
		return json;
	}
}
